﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;

namespace Ecommerce.Models
{
    // You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
    public class ApplicationUser : IdentityUser
    {
        public async Task<ClaimsIdentity> GenerateUserIdentityAsync(ApplicationUserManager manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);            
            // Add custom user claims here
            return userIdentity;            
        }

        [MaxLength(256)]
        public string FullName { get; set; }
        public byte? Gender { get; set; }
        public DateTime? Birthday { get; set; }
        [MaxLength(256)]
        public string PositionInOrganization { get; set; }
    }

    public class ApplicationRole : IdentityRole
    {
        public ApplicationRole() : base()
        {
            
        }

        public ApplicationRole(string name) : base(name)
        {
            
        }

        [MaxLength(512)]
        public string Description { get; set; }
    }

    public class UserManagerDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim>
    {
        public UserManagerDbContext()
            : base("EcommerceContext")
        {
            
        }

        public static UserManagerDbContext Create()
        {
            return new UserManagerDbContext();
        }

        
    }
}